import { UserLayout, TabLayout } from '@/components/layouts'
import Vue from 'vue'
import { USER_INFO } from '../store/mutation-types'

/**
 * 走菜单，走权限控制
 * @type {[null,null]}
 */
export const asyncRouterMap = [
  {
    path: '/',
    name: 'dashboard',
    component: TabLayout,
    meta: { title: '首页' },
    redirect: (to) => {
      const userInfo = Vue.ls.get(USER_INFO)
      if (userInfo.role === 'love_and_care') {
        return '/humanisticConcern/oneMap'
      } else if (userInfo.role === 'key_care') {
        return '/careFamily/largeScreen/index'
      } else {
        return '/dashboard/analysis'
      }
    },
    children: [],
  },
  {
    path: '*',
    redirect: '/404',
    hidden: true,
  },
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login'),
      },
    ],
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/404'),
  },
]
